<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>ctpmv.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="CTPMV.1"></a><a href="ctpmv.f.html#CTPMV.1">CTPMV</a>(UPLO,TRANS,DIAG,N,AP,X,INCX)
<span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      INTEGER INCX,N
      CHARACTER DIAG,TRANS,UPLO
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      COMPLEX AP(*),X(*)
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="CTPMV.13"></a><a href="ctpmv.f.html#CTPMV.1">CTPMV</a>  performs one of the matrix-vector operations
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     x := A*x,   or   x := A'*x,   or   x := conjg( A' )*x,
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where x is an n element vector and  A is an n by n unit, or non-unit,
</span><span class="comment">*</span><span class="comment">  upper or lower triangular matrix, supplied in packed form.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  ==========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  UPLO   - CHARACTER*1.
</span><span class="comment">*</span><span class="comment">           On entry, UPLO specifies whether the matrix is an upper or
</span><span class="comment">*</span><span class="comment">           lower triangular matrix as follows:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              UPLO = 'U' or 'u'   A is an upper triangular matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              UPLO = 'L' or 'l'   A is a lower triangular matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  TRANS  - CHARACTER*1.
</span><span class="comment">*</span><span class="comment">           On entry, TRANS specifies the operation to be performed as
</span><span class="comment">*</span><span class="comment">           follows:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              TRANS = 'N' or 'n'   x := A*x.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              TRANS = 'T' or 't'   x := A'*x.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              TRANS = 'C' or 'c'   x := conjg( A' )*x.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  DIAG   - CHARACTER*1.
</span><span class="comment">*</span><span class="comment">           On entry, DIAG specifies whether or not A is unit
</span><span class="comment">*</span><span class="comment">           triangular as follows:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              DIAG = 'U' or 'u'   A is assumed to be unit triangular.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              DIAG = 'N' or 'n'   A is not assumed to be unit
</span><span class="comment">*</span><span class="comment">                                  triangular.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N      - INTEGER.
</span><span class="comment">*</span><span class="comment">           On entry, N specifies the order of the matrix A.
</span><span class="comment">*</span><span class="comment">           N must be at least zero.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  AP     - COMPLEX          array of DIMENSION at least
</span><span class="comment">*</span><span class="comment">           ( ( n*( n + 1 ) )/2 ).
</span><span class="comment">*</span><span class="comment">           Before entry with  UPLO = 'U' or 'u', the array AP must
</span><span class="comment">*</span><span class="comment">           contain the upper triangular matrix packed sequentially,
</span><span class="comment">*</span><span class="comment">           column by column, so that AP( 1 ) contains a( 1, 1 ),
</span><span class="comment">*</span><span class="comment">           AP( 2 ) and AP( 3 ) contain a( 1, 2 ) and a( 2, 2 )
</span><span class="comment">*</span><span class="comment">           respectively, and so on.
</span><span class="comment">*</span><span class="comment">           Before entry with UPLO = 'L' or 'l', the array AP must
</span><span class="comment">*</span><span class="comment">           contain the lower triangular matrix packed sequentially,
</span><span class="comment">*</span><span class="comment">           column by column, so that AP( 1 ) contains a( 1, 1 ),
</span><span class="comment">*</span><span class="comment">           AP( 2 ) and AP( 3 ) contain a( 2, 1 ) and a( 3, 1 )
</span><span class="comment">*</span><span class="comment">           respectively, and so on.
</span><span class="comment">*</span><span class="comment">           Note that when  DIAG = 'U' or 'u', the diagonal elements of
</span><span class="comment">*</span><span class="comment">           A are not referenced, but are assumed to be unity.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  X      - COMPLEX          array of dimension at least
</span><span class="comment">*</span><span class="comment">           ( 1 + ( n - 1 )*abs( INCX ) ).
</span><span class="comment">*</span><span class="comment">           Before entry, the incremented array X must contain the n
</span><span class="comment">*</span><span class="comment">           element vector x. On exit, X is overwritten with the
</span><span class="comment">*</span><span class="comment">           tranformed vector x.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INCX   - INTEGER.
</span><span class="comment">*</span><span class="comment">           On entry, INCX specifies the increment for the elements of
</span><span class="comment">*</span><span class="comment">           X. INCX must not be zero.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Level 2 Blas routine.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- Written on 22-October-1986.
</span><span class="comment">*</span><span class="comment">     Jack Dongarra, Argonne National Lab.
</span><span class="comment">*</span><span class="comment">     Jeremy Du Croz, Nag Central Office.
</span><span class="comment">*</span><span class="comment">     Sven Hammarling, Nag Central Office.
</span><span class="comment">*</span><span class="comment">     Richard Hanson, Sandia National Labs.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      COMPLEX ZERO
      PARAMETER (ZERO= (0.0E+0,0.0E+0))
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      COMPLEX TEMP
      INTEGER I,INFO,IX,J,JX,K,KK,KX
      LOGICAL NOCONJ,NOUNIT
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL <a name="LSAME.108"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      EXTERNAL <a name="LSAME.109"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL <a name="XERBLA.112"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC CONJG
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input parameters.
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
      IF (.NOT.<a name="LSAME.121"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(UPLO,<span class="string">'U'</span>) .AND. .NOT.<a name="LSAME.121"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(UPLO,<span class="string">'L'</span>)) THEN
          INFO = 1
      ELSE IF (.NOT.<a name="LSAME.123"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(TRANS,<span class="string">'N'</span>) .AND. .NOT.<a name="LSAME.123"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(TRANS,<span class="string">'T'</span>) .AND.
     +         .NOT.<a name="LSAME.124"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(TRANS,<span class="string">'C'</span>)) THEN
          INFO = 2
      ELSE IF (.NOT.<a name="LSAME.126"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(DIAG,<span class="string">'U'</span>) .AND. .NOT.<a name="LSAME.126"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(DIAG,<span class="string">'N'</span>)) THEN
          INFO = 3
      ELSE IF (N.LT.0) THEN
          INFO = 4
      ELSE IF (INCX.EQ.0) THEN
          INFO = 7
      END IF
      IF (INFO.NE.0) THEN
          CALL <a name="XERBLA.134"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>(<span class="string">'<a name="CTPMV.134"></a><a href="ctpmv.f.html#CTPMV.1">CTPMV</a> '</span>,INFO)
          RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible.
</span><span class="comment">*</span><span class="comment">
</span>      IF (N.EQ.0) RETURN
<span class="comment">*</span><span class="comment">
</span>      NOCONJ = <a name="LSAME.142"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(TRANS,<span class="string">'T'</span>)
      NOUNIT = <a name="LSAME.143"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(DIAG,<span class="string">'N'</span>)
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Set up the start point in X if the increment is not unity. This
</span><span class="comment">*</span><span class="comment">     will be  ( N - 1 )*INCX  too small for descending loops.
</span><span class="comment">*</span><span class="comment">
</span>      IF (INCX.LE.0) THEN
          KX = 1 - (N-1)*INCX
      ELSE IF (INCX.NE.1) THEN
          KX = 1
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Start the operations. In this version the elements of AP are
</span><span class="comment">*</span><span class="comment">     accessed sequentially with one pass through AP.
</span><span class="comment">*</span><span class="comment">
</span>      IF (<a name="LSAME.157"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(TRANS,<span class="string">'N'</span>)) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Form  x:= A*x.
</span><span class="comment">*</span><span class="comment">
</span>          IF (<a name="LSAME.161"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(UPLO,<span class="string">'U'</span>)) THEN
              KK = 1
              IF (INCX.EQ.1) THEN
                  DO 20 J = 1,N
                      IF (X(J).NE.ZERO) THEN
                          TEMP = X(J)
                          K = KK
                          DO 10 I = 1,J - 1
                              X(I) = X(I) + TEMP*AP(K)
                              K = K + 1
   10                     CONTINUE
                          IF (NOUNIT) X(J) = X(J)*AP(KK+J-1)
                      END IF
                      KK = KK + J
   20             CONTINUE
              ELSE
                  JX = KX
                  DO 40 J = 1,N
                      IF (X(JX).NE.ZERO) THEN
                          TEMP = X(JX)
                          IX = KX
                          DO 30 K = KK,KK + J - 2
                              X(IX) = X(IX) + TEMP*AP(K)
                              IX = IX + INCX
   30                     CONTINUE
                          IF (NOUNIT) X(JX) = X(JX)*AP(KK+J-1)
                      END IF
                      JX = JX + INCX
                      KK = KK + J
   40             CONTINUE
              END IF
          ELSE
              KK = (N* (N+1))/2
              IF (INCX.EQ.1) THEN
                  DO 60 J = N,1,-1
                      IF (X(J).NE.ZERO) THEN
                          TEMP = X(J)
                          K = KK
                          DO 50 I = N,J + 1,-1
                              X(I) = X(I) + TEMP*AP(K)
                              K = K - 1
   50                     CONTINUE
                          IF (NOUNIT) X(J) = X(J)*AP(KK-N+J)
                      END IF
                      KK = KK - (N-J+1)
   60             CONTINUE
              ELSE
                  KX = KX + (N-1)*INCX
                  JX = KX
                  DO 80 J = N,1,-1
                      IF (X(JX).NE.ZERO) THEN
                          TEMP = X(JX)
                          IX = KX
                          DO 70 K = KK,KK - (N- (J+1)),-1
                              X(IX) = X(IX) + TEMP*AP(K)
                              IX = IX - INCX
   70                     CONTINUE
                          IF (NOUNIT) X(JX) = X(JX)*AP(KK-N+J)
                      END IF
                      JX = JX - INCX
                      KK = KK - (N-J+1)
   80             CONTINUE
              END IF
          END IF
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Form  x := A'*x  or  x := conjg( A' )*x.
</span><span class="comment">*</span><span class="comment">
</span>          IF (<a name="LSAME.229"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(UPLO,<span class="string">'U'</span>)) THEN
              KK = (N* (N+1))/2
              IF (INCX.EQ.1) THEN
                  DO 110 J = N,1,-1
                      TEMP = X(J)
                      K = KK - 1
                      IF (NOCONJ) THEN
                          IF (NOUNIT) TEMP = TEMP*AP(KK)
                          DO 90 I = J - 1,1,-1
                              TEMP = TEMP + AP(K)*X(I)
                              K = K - 1
   90                     CONTINUE
                      ELSE
                          IF (NOUNIT) TEMP = TEMP*CONJG(AP(KK))
                          DO 100 I = J - 1,1,-1
                              TEMP = TEMP + CONJG(AP(K))*X(I)
                              K = K - 1
  100                     CONTINUE
                      END IF
                      X(J) = TEMP
                      KK = KK - J
  110             CONTINUE
              ELSE
                  JX = KX + (N-1)*INCX
                  DO 140 J = N,1,-1
                      TEMP = X(JX)
                      IX = JX
                      IF (NOCONJ) THEN
                          IF (NOUNIT) TEMP = TEMP*AP(KK)
                          DO 120 K = KK - 1,KK - J + 1,-1
                              IX = IX - INCX
                              TEMP = TEMP + AP(K)*X(IX)
  120                     CONTINUE
                      ELSE
                          IF (NOUNIT) TEMP = TEMP*CONJG(AP(KK))
                          DO 130 K = KK - 1,KK - J + 1,-1
                              IX = IX - INCX
                              TEMP = TEMP + CONJG(AP(K))*X(IX)
  130                     CONTINUE
                      END IF
                      X(JX) = TEMP
                      JX = JX - INCX
                      KK = KK - J
  140             CONTINUE
              END IF
          ELSE
              KK = 1
              IF (INCX.EQ.1) THEN
                  DO 170 J = 1,N
                      TEMP = X(J)
                      K = KK + 1
                      IF (NOCONJ) THEN
                          IF (NOUNIT) TEMP = TEMP*AP(KK)
                          DO 150 I = J + 1,N
                              TEMP = TEMP + AP(K)*X(I)
                              K = K + 1
  150                     CONTINUE
                      ELSE
                          IF (NOUNIT) TEMP = TEMP*CONJG(AP(KK))
                          DO 160 I = J + 1,N
                              TEMP = TEMP + CONJG(AP(K))*X(I)
                              K = K + 1
  160                     CONTINUE
                      END IF
                      X(J) = TEMP
                      KK = KK + (N-J+1)
  170             CONTINUE
              ELSE
                  JX = KX
                  DO 200 J = 1,N
                      TEMP = X(JX)
                      IX = JX
                      IF (NOCONJ) THEN
                          IF (NOUNIT) TEMP = TEMP*AP(KK)
                          DO 180 K = KK + 1,KK + N - J
                              IX = IX + INCX
                              TEMP = TEMP + AP(K)*X(IX)
  180                     CONTINUE
                      ELSE
                          IF (NOUNIT) TEMP = TEMP*CONJG(AP(KK))
                          DO 190 K = KK + 1,KK + N - J
                              IX = IX + INCX
                              TEMP = TEMP + CONJG(AP(K))*X(IX)
  190                     CONTINUE
                      END IF
                      X(JX) = TEMP
                      JX = JX + INCX
                      KK = KK + (N-J+1)
  200             CONTINUE
              END IF
          END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="CTPMV.324"></a><a href="ctpmv.f.html#CTPMV.1">CTPMV</a> .
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
